package com.cly.controller;

import com.cly.base.controller.BaseController;
import com.cly.entity.ProblemBank;
import com.cly.result.JsonRequest;
import com.cly.service.IProblemBankService;
import com.cly.vo.ProblemBankVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 题库表 控制器
 *
 * @author by 春风能解释
 * <p>
 * 2024-06-05
 */
@RestController
@RequestMapping("/proBank")
@Tag(name = "题库表控制类", description = "题库表操作访问接口")
public class ProblemBankController extends BaseController<IProblemBankService, ProblemBank> {

    /**
     * 条件查看所有题库
     *
     * @param problemBank 条件
     * @return JSON
     */
    @GetMapping("/listAll")
    @Operation(summary = "查看所有题库")
    public JsonRequest<List<ProblemBank>> lookAllProblemBank(
            @Parameter(description = "条件")
            ProblemBank problemBank) {
        return baseService.lookAllProblemBank(problemBank);
    }

    /**
     * 查看题库
     *
     * @param current     页码
     * @param size        页长
     * @param problemBank 条件
     * @return JSON
     */
    @GetMapping("/list")
    @Operation(summary = "查看题库")
    public JsonRequest<List<ProblemBankVo>> lookProblemBank(
            @Parameter(description = "页码", required = true)
            @RequestParam Integer current,
            @Parameter(description = "页长", required = true)
            @RequestParam Integer size,
            @Parameter(description = "条件")
            ProblemBank problemBank) {
        return baseService.lookProblemBank(current, size, problemBank);
    }

    /**
     * 添加题库
     *
     * @param problemBank 题库
     * @return JSON
     */
    @PostMapping
    @Operation(summary = "添加题库")
    public JsonRequest<Integer> addProblemBank(
            @Parameter(description = "题库数据", required = true)
            @RequestBody ProblemBank problemBank) {
        return baseService.addProblemBank(problemBank);
    }

    /**
     * 修改题库
     *
     * @param problemBank 题库
     * @return JSON
     */
    @PutMapping
    @Operation(summary = "修改题库")
    public JsonRequest<Integer> updateProblemBank(
            @Parameter(description = "题库数据", required = true)
            @RequestBody ProblemBank problemBank) {
        return baseService.updateProblemBank(problemBank);
    }

    /**
     * 删除题库
     *
     * @param ids 题库id
     * @return JSON
     */
    @DeleteMapping
    @Operation(summary = "删除题库")
    public JsonRequest<Integer> deleteProblemBank(
            @Parameter(description = "题库id", required = true)
            @RequestBody List<Long> ids) {
        return baseService.deleteProblemBank(ids);
    }
}




